<?php
	class ArrayHelper
	{
		public static function toTable ( $result_set )
		{	
			if( count($result_set) == 0 ){ return ''; }
		
			$table_headers = array_keys($result_set[0]);
			
			$html_table = '';
			
			$html_table .= '<table class="roguemvc-arrayhelper-totable">';
			$html_table .= '<thead><tr>';
			
			foreach($table_headers as $key)
			{
				$html_table .= '<th>'.$key.'</th>';	
			}
			
			$html_table .= '</tr></thead>';
			$html_table .= '<tbody>';

			foreach($result_set as $rownum => $row)
			{			
				$html_table .= '<tr>';
				foreach($table_headers as $index => $key)
				{
					$html_table .= '<td>'.$row[$key].'</td>';	
				}
				$html_table .= '</tr>';
			}
			
			$html_table .= '</tbody>';
			$html_table .= '</table>';
			
			return $html_table;
		}
	}
?>